Convert attribute with values to attribute with numbers

Hi everyone, this is my second topic here.
I've started to use Doors recently for risk management but I'm new to database and coding. My problem is pretty basic and hope i explain it correctly.

I have 3 modules 1, 2 and 3; each with object O1, O2 and O3 respectively and several attributes 1A1, 1A2, 1A3... for module 1; 2A1, 2A2.. for module 2 and so on. Objects in 3 are linked to Objects in 2 and Objects in 2 are linked to Objects in 1

Using the analysis wizard in module 2, I imported attributes 1A1 and 1A2 from module 1. I need to have 1A2 displayed in module 3 so i converted 1A2 layout dxl to attribute dxl 1A2'.

Type of 1A2 is text and can have 5 different value: word1, word2, word3 and so on.

I would like to have an attribute 3A1 (type number) in module 3 which depends of 1A2 attribute, let's say 1=word1; 2=word2 etc

How can i set the attribute so that it does this automatically?
Something like: If 1A2 = word1 then 3A1 = 1

Then i would also like to have another attribute 3A2 with "ok, not ok"
If 3A1 = 1 or 2 or 3 then 3A2= ok
IF 3A1 = 4 or 5 then 3A2 = not ok

I hope my "problem" is clear and that you can help me

Thanks in advance
Manu
Manu23 - Wed May 16 10:52:23 EDT 2012

Re: Convert attribute with values to attribute with numbers
llandale - Wed May 16 12:36:30 EDT 2012

I think you said you used the Analysis Wizard to "display" values in m3 from linked objects in m1, converted it to Attr-DXL, and now figure to do serious edits to that code to get exactly what you want. That's a very reasonable approach.

I think you want an integer attr "3A1" that is also your attr DXL with the "if" statement you suggest, along with "elseif" statements for the other possibilities.

oIn1 = find linked object in m1.  Lets hope there is only one such linked object string Value = oIn1.
"1A2" 

int iResult = -1 

if     (Value == 
"word1") then iResult = 1 elseif(Value == 
"word2") then iResult = 2 elseiif.. 

else iResult = -1 obj.attrDXLName = iResult

Then create another enumerated Attr-DXL in m3 with enumerations "ok" amd "not ok" and perhaps "error" and an empty enum. That code is rather trivial and ignores links:



int iValue = obj.
"3A1" string Result 

if     (iValue == 0) then Result = 
""   
// zero is "null" for an integer elseif(iValue == 1 or iValue == 2 or iValue == 3) then Result = 
"ok" elseif(iValue == 4 or iValue == 5) then Result = 
"not ok" 

else Result = 
"error" obj.AttrDXLName = Result

If o3 can be linked indirectly to more than one o1. Perhaps then instead of assigning "Result = 1" you assign it to the max of Result or 1: "(Result >? 1)" or the min "(Result <? 1)" ; pre-setting Result = 0 or some very high number

-Louie

Re: Convert attribute with values to attribute with numbers
Manu23 - Mon May 21 04:03:24 EDT 2012

llandale - Wed May 16 12:36:30 EDT 2012
I think you said you used the Analysis Wizard to "display" values in m3 from linked objects in m1, converted it to Attr-DXL, and now figure to do serious edits to that code to get exactly what you want. That's a very reasonable approach.

I think you want an integer attr "3A1" that is also your attr DXL with the "if" statement you suggest, along with "elseif" statements for the other possibilities.


oIn1 = find linked object in m1.  Lets hope there is only one such linked object string Value = oIn1.
"1A2" 

int iResult = -1 

if     (Value == 
"word1") then iResult = 1 elseif(Value == 
"word2") then iResult = 2 elseiif.. 

else iResult = -1 obj.attrDXLName = iResult

Then create another enumerated Attr-DXL in m3 with enumerations "ok" amd "not ok" and perhaps "error" and an empty enum. That code is rather trivial and ignores links:



int iValue = obj.
"3A1" string Result 

if     (iValue == 0) then Result = 
""   
// zero is "null" for an integer elseif(iValue == 1 or iValue == 2 or iValue == 3) then Result = 
"ok" elseif(iValue == 4 or iValue == 5) then Result = 
"not ok" 

else Result = 
"error" obj.AttrDXLName = Result

If o3 can be linked indirectly to more than one o1. Perhaps then instead of assigning "Result = 1" you assign it to the max of Result or 1: "(Result >? 1)" or the min "(Result <? 1)" ; pre-setting Result = 0 or some very high number

-Louie

Thanks Louie for your reply.
Where do i need to paste this code? Do i need to create the text in notepad and look it up when i create the attibute (dxl attribute, browse)?
Regarding the 1st code:

oIn1 = find linked object in m1. Lets hope there is only one such linked object: There are a many to one; or one to one and; a one to many relation ship. Also if the module is not called 1 but FMEA, do i need to write the code like this? oInFMEA

string Value = oIn1."1A2"
int iResult = -1
if (Value == "word1") then iResult = 1
elseif(Value == "word2") then iResult = 2
elseiif..
else iResult = -1
obj.attrDXLName = iResult

Thanks again

Re: Convert attribute with values to attribute with numbers
Manu23 - Mon May 21 05:40:59 EDT 2012

Manu23 - Mon May 21 04:03:24 EDT 2012
Thanks Louie for your reply.
Where do i need to paste this code? Do i need to create the text in notepad and look it up when i create the attibute (dxl attribute, browse)?
Regarding the 1st code:

oIn1 = find linked object in m1. Lets hope there is only one such linked object: There are a many to one; or one to one and; a one to many relation ship. Also if the module is not called 1 but FMEA, do i need to write the code like this? oInFMEA

string Value = oIn1."1A2"
int iResult = -1
if (Value == "word1") then iResult = 1
elseif(Value == "word2") then iResult = 2
elseiif..
else iResult = -1
obj.attrDXLName = iResult

Thanks again

Don't take in account above questions, just noticed how to create dxl but don't yet the right access to do so. Going to check first with the IT within my company.

Re: Convert attribute with values to attribute with numbers
llandale - Mon May 21 13:42:18 EDT 2012

Manu23 - Mon May 21 04:03:24 EDT 2012
Thanks Louie for your reply.
Where do i need to paste this code? Do i need to create the text in notepad and look it up when i create the attibute (dxl attribute, browse)?
Regarding the 1st code:

oIn1 = find linked object in m1. Lets hope there is only one such linked object: There are a many to one; or one to one and; a one to many relation ship. Also if the module is not called 1 but FMEA, do i need to write the code like this? oInFMEA

string Value = oIn1."1A2"
int iResult = -1
if (Value == "word1") then iResult = 1
elseif(Value == "word2") then iResult = 2
elseiif..
else iResult = -1
obj.attrDXLName = iResult

Thanks again

It seems likely the database has disallowed folks from running DXL. When you get that right, you can indeed "browse" for a file, but you can also get "new" or "current" dxl, get a window, and paste or type it in directly.

"oIn1": There are quite a few folks who can keep track of 100s of details such as variable names, and don't need any sort of discipline. They could call the 1st one A, second B etc and won't get confused. I'm at the other end of the spectrum (mentally) and if I don't take time to acurately name my variables I will get hopelessly lost even in the most routine function. And, I may say, the next dude to read the function appreciates my effort.

So no, you don't have to rename the attribute "oInFEMA"; however I certainly would do something like that; "oFEMA" most likely.

-Louie